package com.zkthink.zhl.order.dao;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.mapper.SuperMapper;
import com.zkthink.clh.order.dto.ChlOrderPageDTO;
import com.zkthink.clh.order.dto.StoreBillDto;
import com.zkthink.clh.order.entity.ChlOrder;
import com.zkthink.clh.order.vo.GetOederVo;
import com.zkthink.clh.order.vo.MyOederVo;
import com.zkthink.clh.order.vo.MyqianbaodetailsVo;
import com.zkthink.clh.order.vo.StoreBillVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 车惠龙订单表
 * </p>
 *
 * @author chenke
 * @date 2022-04-24
 */
@Repository
public interface ChlOrderMapper extends SuperMapper<ChlOrder> {

     List<MyOederVo> myOeder(Long mid);
     GetOederVo getOeder(Long id);
     @Select("select id,notes,pay_sum from chl_order where mid = #{mid}")
     List<ChlOrder> findByMid(Long mid);
     @Select("select notes,pay_sum paySum,ifnull(pay_time,c.create_time) payTime ,title,backgroundimg,store_name storeName from chl_order c Left join ceres_store_project a on c.projectid=a.id LEFT JOIN ceres_store b on c.store_id = b.id where c.id=#{id}")
     MyqianbaodetailsVo storeName(Long id);

     @Select("select order_status orderStatus,pay_sum paySum,pay_time payTime,notes from chl_order where id = #{id}")
     MyqianbaodetailsVo findByid(Long id);

     @Select("select * from chl_order where order_code = #{orderCode} and store_id = #{storeId} and order_status != 4")
     ChlOrder findByOrderCodeChlOrder(@Param("orderCode")String orderCode,@Param("storeId")Long storeId);
     List<ChlOrder> myqianbao(@Param("mid") Long mid,@Param("type") Integer type);

    List<MyqianbaodetailsVo> storeTxBill(@Param("dto") StoreBillDto dto);

     List<StoreBillVo> storeBill(@Param("dto") StoreBillDto dto);

    IPage<ChlOrder> page(IPage page,@Param("dto") ChlOrderPageDTO model);
    @Update("update chl_order set is_delete = 1 where id = #{id}")
    int updateChlOrderDelete(Long id);
}
